﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using OA.Model;
using OA.DBUtility;
using System.Collections.Generic;
namespace OA.Manager
{
    /// <summary>
    /// 数据访问类:DictionaryType
    /// </summary>
    public partial class DictionaryTypeManager
    {
        private SqlService<DictionaryTypeInfo> _sqlService = null;

        public DictionaryTypeManager()
        {
            _sqlService = new SqlService<DictionaryTypeInfo>();
        }

        #region  Method

        /// <summary>
        /// 插入新记录
        /// </summary>
        /// <param name="dictionaryTypeInfo"></param>
        /// <returns></returns>
        public bool InsertDictionaryTypeInfo(DictionaryTypeInfo dictionaryTypeInfo)
        {
            return _sqlService.SaveEntity(dictionaryTypeInfo);
        }

        /// <summary>
        /// 根据打印任务ID获得打印任务信息
        /// </summary>
        /// <param name="taskID"></param>
        /// <returns></returns>
        public DictionaryTypeInfo GetDictionaryTypeInfoByID(int ID)
        {
            return _sqlService.GetSingleByFields(new Dictionary<string, object> { { "ID", ID } }, null);
        }

        public List<DictionaryTypeInfo> GetDictionaryTypeInfoAll(int pageIndex, int pageSize,out int total)
        {
            return _sqlService.GetPaged(pageIndex, pageSize, out total);
        }
        public List<DictionaryTypeInfo> GetDictionaryTypeInfoAll()
        {
            return _sqlService.GetAllBySqlString("select * from DictionaryType");
        }

        public int GetDictionaryTypeTotal()
        {
            return Convert.ToInt32(_sqlService.ExecuteScalar("select count(*) from DictionaryType"));
        }

        /// <summary>
        /// 判断该打印任务是否存在
        /// </summary>
        /// <param name="dictionaryTypeInfo"></param>
        /// <returns></returns>
        public bool IsExistDictionaryTypeInfo(DictionaryTypeInfo dictionaryTypeInfo)
        {
            return _sqlService.IsExist(dictionaryTypeInfo);
        }

        /// <summary>
        /// 根据指定的字段更新，字段名是数据库中对应的名称
        /// </summary>
        /// <param name="dictionaryTypeInfo"></param>
        /// <param name="needUpdateFields"></param>
        /// <returns></returns>
        public bool UpdateDictionaryTypeInfo(DictionaryTypeInfo dictionaryTypeInfo, List<string> needUpdateFields)
        {
            return _sqlService.UpdateByFields(dictionaryTypeInfo, needUpdateFields);
        }

        /// <summary>
        /// 删除该检查任务
        /// </summary>
        /// <param name="dictionaryTypeInfo"></param>
        /// <returns></returns>
        public bool DeleteDictionaryTypeInfo(DictionaryTypeInfo dictionaryTypeInfo)
        {
            return _sqlService.DeleteEntity(dictionaryTypeInfo);
        }

        #endregion  Method
    }
}

